package logic

import (
	"context"
	"hotel/hotelrpc/hotelrpc"
	"hotel/pkg"

	"hotel/hotelapi/internal/svc"
	"hotel/hotelapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectHotelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectHotelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectHotelLogic {
	return &PerfectHotelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectHotelLogic) PerfectHotel(req *types.PerfectHotelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	hotel, err := l.svcCtx.HotelRpc.PerfectHotel(l.ctx, &hotelrpc.PerfectHotelRequest{
		Id:       req.Id,
		Avatar:   req.Avatar,
		Gender:   req.Gender,
		Self:     req.Self,
		Name:     req.Name,
		Nickname: req.Nickname,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: pkg.Tri(err.Error()),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "完善个人信息成功",
		Data:    hotel.Id,
	}, nil
}
